﻿using Simple.Framework.Configuration;
using Simple.PrettyNet.Net;
using Simple.PrettyNet;
using Simple.WindowsServer;
using SqlSugar;

namespace Simple.FileBackServer
{
	internal class Program
	{
		static void Main(string[] args)
		{
			IHost host = Host.BuilderHost().Regster((container) =>
			{
				//容器模块，注册需要实例的对象，容器可以自动创建对象，解决对象的依赖。
				//container.RegisterSingleton<IMessageHandle, IDTMessageHandle>();
				//container.Register<IContext, IDTContext>();
				//container.RegisterSingleton<IRedisClientService, RedisClientService>();
				//container.Register<VersionUpgradeHanlder>();
				//container.RegisterSingleton<IConfiguration, IDTConfiguration>();
				string dbPath = Path.Combine(AppContext.BaseDirectory,"DB","db.db");
				ConnectionConfig connectionConfig = new ConnectionConfig() { 
				DbType=DbType.Sqlite,
				ConnectionString= $"Data Source={dbPath};Cache=Shared",
				IsAutoCloseConnection=true,
				};
				SqlSugarClient clinet = new SqlSugarClient(connectionConfig);
				container.RegistSingletonInstance<ISqlSugarClient,SqlSugarClient>(clinet);
			}).
			RegisterSchedule((scheduleManager) =>
				{
					//注册任务
					//任务是固定时间间隔执行
					//一个任务周期为 任务中逻辑时间+等待时间
					//通常任务时间比较少，适合做心跳检查
					//scheduleManager.Register<TestSchedule>();
					//scheduleManager.Register<CheckHeartSchedule>();
					//scheduleManager.Register<CheckCommandSchedule>();

				})
			.ConfigutionPipeline((host) =>
			{
				//host.ConfigutionPipeline<VerifyPipeline>();
				//host.ConfigutionPipeline<AuthenticationPipeLine>();
			}).Start().
			UseWindowsService();
			Console.ReadLine();
		}
	}
}